﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;

namespace UniRx
{
	// Token: 0x0200021C RID: 540
	[Serializable]
	public abstract class Notification<T> : IEquatable<Notification<T>>
	{
		// Token: 0x06000CB8 RID: 3256 RVA: 0x0003E420 File Offset: 0x0003C820
		protected internal Notification()
		{
		}

		// Token: 0x170000F5 RID: 245
		// (get) Token: 0x06000CB9 RID: 3257
		public abstract T Value { get; }

		// Token: 0x170000F6 RID: 246
		// (get) Token: 0x06000CBA RID: 3258
		public abstract bool HasValue { get; }

		// Token: 0x170000F7 RID: 247
		// (get) Token: 0x06000CBB RID: 3259
		public abstract Exception Exception { get; }

		// Token: 0x170000F8 RID: 248
		// (get) Token: 0x06000CBC RID: 3260
		public abstract NotificationKind Kind { get; }

		// Token: 0x06000CBD RID: 3261
		public abstract bool Equals(Notification<T> other);

		// Token: 0x06000CBE RID: 3262 RVA: 0x0003E428 File Offset: 0x0003C828
		public static bool operator ==(Notification<T> left, Notification<T> right)
		{
			return object.ReferenceEquals(left, right) || (left != null && right != null && left.Equals(right));
		}

		// Token: 0x06000CBF RID: 3263 RVA: 0x0003E44D File Offset: 0x0003C84D
		public static bool operator !=(Notification<T> left, Notification<T> right)
		{
			return !(left == right);
		}

		// Token: 0x06000CC0 RID: 3264 RVA: 0x0003E459 File Offset: 0x0003C859
		public override bool Equals(object obj)
		{
			return this.Equals(obj as Notification<T>);
		}

		// Token: 0x06000CC1 RID: 3265
		public abstract void Accept(IObserver<T> observer);

		// Token: 0x06000CC2 RID: 3266
		public abstract TResult Accept<TResult>(IObserver<T, TResult> observer);

		// Token: 0x06000CC3 RID: 3267
		public abstract void Accept(Action<T> onNext, Action<Exception> onError, Action onCompleted);

		// Token: 0x06000CC4 RID: 3268
		public abstract TResult Accept<TResult>(Func<T, TResult> onNext, Func<Exception, TResult> onError, Func<TResult> onCompleted);

		// Token: 0x06000CC5 RID: 3269 RVA: 0x0003E467 File Offset: 0x0003C867
		public IObservable<T> ToObservable()
		{
			return this.ToObservable(Scheduler.Immediate);
		}

		// Token: 0x06000CC6 RID: 3270 RVA: 0x0003E474 File Offset: 0x0003C874
		public IObservable<T> ToObservable(IScheduler scheduler)
		{
			//Notification<T>.<ToObservable>c__AnonStorey0 <ToObservable>c__AnonStorey = new Notification<T>.<ToObservable>c__AnonStorey0();
			//<ToObservable>c__AnonStorey.scheduler = scheduler;
			//<ToObservable>c__AnonStorey.$this = this;
			//if (<ToObservable>c__AnonStorey.scheduler == null)
			//{
			//	throw new ArgumentNullException("scheduler");
			//}
			//return Observable.Create<T>((IObserver<T> observer) => <ToObservable>c__AnonStorey.scheduler.Schedule(delegate()
			//{
			//	<ToObservable>c__AnonStorey.Accept(observer);
			//	if (<ToObservable>c__AnonStorey.Kind == NotificationKind.OnNext)
			//	{
			//		observer.OnCompleted();
			//	}
			//}));
			return null;
		}

		// Token: 0x0200021D RID: 541
		[DebuggerDisplay("OnNext({Value})")]
		[Serializable]
		internal sealed class OnNextNotification : Notification<T>
		{
			// Token: 0x06000CC7 RID: 3271 RVA: 0x0003E4BC File Offset: 0x0003C8BC
			public OnNextNotification(T value)
			{
				this.value = value;
			}

			// Token: 0x170000F9 RID: 249
			// (get) Token: 0x06000CC8 RID: 3272 RVA: 0x0003E4CB File Offset: 0x0003C8CB
			public override T Value
			{
				get
				{
					return this.value;
				}
			}

			// Token: 0x170000FA RID: 250
			// (get) Token: 0x06000CC9 RID: 3273 RVA: 0x0003E4D3 File Offset: 0x0003C8D3
			public override Exception Exception
			{
				get
				{
					return null;
				}
			}

			// Token: 0x170000FB RID: 251
			// (get) Token: 0x06000CCA RID: 3274 RVA: 0x0003E4D6 File Offset: 0x0003C8D6
			public override bool HasValue
			{
				get
				{
					return true;
				}
			}

			// Token: 0x170000FC RID: 252
			// (get) Token: 0x06000CCB RID: 3275 RVA: 0x0003E4D9 File Offset: 0x0003C8D9
			public override NotificationKind Kind
			{
				get
				{
					return NotificationKind.OnNext;
				}
			}

			// Token: 0x06000CCC RID: 3276 RVA: 0x0003E4DC File Offset: 0x0003C8DC
			public override int GetHashCode()
			{
				return EqualityComparer<T>.Default.GetHashCode(this.Value);
			}

			// Token: 0x06000CCD RID: 3277 RVA: 0x0003E4F0 File Offset: 0x0003C8F0
			public override bool Equals(Notification<T> other)
			{
				return object.ReferenceEquals(this, other) || (!object.ReferenceEquals(other, null) && other.Kind == NotificationKind.OnNext && EqualityComparer<T>.Default.Equals(this.Value, other.Value));
			}

			// Token: 0x06000CCE RID: 3278 RVA: 0x0003E53C File Offset: 0x0003C93C
			public override string ToString()
			{
				return string.Format(CultureInfo.CurrentCulture, "OnNext({0})", new object[]
				{
					this.Value
				});
			}

			// Token: 0x06000CCF RID: 3279 RVA: 0x0003E561 File Offset: 0x0003C961
			public override void Accept(IObserver<T> observer)
			{
				if (observer == null)
				{
					throw new ArgumentNullException("observer");
				}
				observer.OnNext(this.Value);
			}

			// Token: 0x06000CD0 RID: 3280 RVA: 0x0003E580 File Offset: 0x0003C980
			public override TResult Accept<TResult>(IObserver<T, TResult> observer)
			{
				if (observer == null)
				{
					throw new ArgumentNullException("observer");
				}
				return observer.OnNext(this.Value);
			}

			// Token: 0x06000CD1 RID: 3281 RVA: 0x0003E5A0 File Offset: 0x0003C9A0
			public override void Accept(Action<T> onNext, Action<Exception> onError, Action onCompleted)
			{
				if (onNext == null)
				{
					throw new ArgumentNullException("onNext");
				}
				if (onError == null)
				{
					throw new ArgumentNullException("onError");
				}
				if (onCompleted == null)
				{
					throw new ArgumentNullException("onCompleted");
				}
				onNext(this.Value);
			}

			// Token: 0x06000CD2 RID: 3282 RVA: 0x0003E5EC File Offset: 0x0003C9EC
			public override TResult Accept<TResult>(Func<T, TResult> onNext, Func<Exception, TResult> onError, Func<TResult> onCompleted)
			{
				if (onNext == null)
				{
					throw new ArgumentNullException("onNext");
				}
				if (onError == null)
				{
					throw new ArgumentNullException("onError");
				}
				if (onCompleted == null)
				{
					throw new ArgumentNullException("onCompleted");
				}
				return onNext(this.Value);
			}

			// Token: 0x04000746 RID: 1862
			private T value;
		}

		// Token: 0x0200021E RID: 542
		[DebuggerDisplay("OnError({Exception})")]
		[Serializable]
		internal sealed class OnErrorNotification : Notification<T>
		{
			// Token: 0x06000CD3 RID: 3283 RVA: 0x0003E638 File Offset: 0x0003CA38
			public OnErrorNotification(Exception exception)
			{
				this.exception = exception;
			}

			// Token: 0x170000FD RID: 253
			// (get) Token: 0x06000CD4 RID: 3284 RVA: 0x0003E647 File Offset: 0x0003CA47
			public override T Value
			{
				get
				{
					throw this.exception;
				}
			}

			// Token: 0x170000FE RID: 254
			// (get) Token: 0x06000CD5 RID: 3285 RVA: 0x0003E64F File Offset: 0x0003CA4F
			public override Exception Exception
			{
				get
				{
					return this.exception;
				}
			}

			// Token: 0x170000FF RID: 255
			// (get) Token: 0x06000CD6 RID: 3286 RVA: 0x0003E657 File Offset: 0x0003CA57
			public override bool HasValue
			{
				get
				{
					return false;
				}
			}

			// Token: 0x17000100 RID: 256
			// (get) Token: 0x06000CD7 RID: 3287 RVA: 0x0003E65A File Offset: 0x0003CA5A
			public override NotificationKind Kind
			{
				get
				{
					return NotificationKind.OnError;
				}
			}

			// Token: 0x06000CD8 RID: 3288 RVA: 0x0003E65D File Offset: 0x0003CA5D
			public override int GetHashCode()
			{
				return this.Exception.GetHashCode();
			}

			// Token: 0x06000CD9 RID: 3289 RVA: 0x0003E66A File Offset: 0x0003CA6A
			public override bool Equals(Notification<T> other)
			{
				return object.ReferenceEquals(this, other) || (!object.ReferenceEquals(other, null) && other.Kind == NotificationKind.OnError && object.Equals(this.Exception, other.Exception));
			}

			// Token: 0x06000CDA RID: 3290 RVA: 0x0003E6A7 File Offset: 0x0003CAA7
			public override string ToString()
			{
				return string.Format(CultureInfo.CurrentCulture, "OnError({0})", new object[]
				{
					this.Exception.GetType().FullName
				});
			}

			// Token: 0x06000CDB RID: 3291 RVA: 0x0003E6D1 File Offset: 0x0003CAD1
			public override void Accept(IObserver<T> observer)
			{
				if (observer == null)
				{
					throw new ArgumentNullException("observer");
				}
				observer.OnError(this.Exception);
			}

			// Token: 0x06000CDC RID: 3292 RVA: 0x0003E6F0 File Offset: 0x0003CAF0
			public override TResult Accept<TResult>(IObserver<T, TResult> observer)
			{
				if (observer == null)
				{
					throw new ArgumentNullException("observer");
				}
				return observer.OnError(this.Exception);
			}

			// Token: 0x06000CDD RID: 3293 RVA: 0x0003E710 File Offset: 0x0003CB10
			public override void Accept(Action<T> onNext, Action<Exception> onError, Action onCompleted)
			{
				if (onNext == null)
				{
					throw new ArgumentNullException("onNext");
				}
				if (onError == null)
				{
					throw new ArgumentNullException("onError");
				}
				if (onCompleted == null)
				{
					throw new ArgumentNullException("onCompleted");
				}
				onError(this.Exception);
			}

			// Token: 0x06000CDE RID: 3294 RVA: 0x0003E75C File Offset: 0x0003CB5C
			public override TResult Accept<TResult>(Func<T, TResult> onNext, Func<Exception, TResult> onError, Func<TResult> onCompleted)
			{
				if (onNext == null)
				{
					throw new ArgumentNullException("onNext");
				}
				if (onError == null)
				{
					throw new ArgumentNullException("onError");
				}
				if (onCompleted == null)
				{
					throw new ArgumentNullException("onCompleted");
				}
				return onError(this.Exception);
			}

			// Token: 0x04000747 RID: 1863
			private Exception exception;
		}

		// Token: 0x0200021F RID: 543
		[DebuggerDisplay("OnCompleted()")]
		[Serializable]
		internal sealed class OnCompletedNotification : Notification<T>
		{
			// Token: 0x17000101 RID: 257
			// (get) Token: 0x06000CE0 RID: 3296 RVA: 0x0003E7B0 File Offset: 0x0003CBB0
			public override T Value
			{
				get
				{
					throw new InvalidOperationException("No Value");
				}
			}

			// Token: 0x17000102 RID: 258
			// (get) Token: 0x06000CE1 RID: 3297 RVA: 0x0003E7BC File Offset: 0x0003CBBC
			public override Exception Exception
			{
				get
				{
					return null;
				}
			}

			// Token: 0x17000103 RID: 259
			// (get) Token: 0x06000CE2 RID: 3298 RVA: 0x0003E7BF File Offset: 0x0003CBBF
			public override bool HasValue
			{
				get
				{
					return false;
				}
			}

			// Token: 0x17000104 RID: 260
			// (get) Token: 0x06000CE3 RID: 3299 RVA: 0x0003E7C2 File Offset: 0x0003CBC2
			public override NotificationKind Kind
			{
				get
				{
					return NotificationKind.OnCompleted;
				}
			}

			// Token: 0x06000CE4 RID: 3300 RVA: 0x0003E7C5 File Offset: 0x0003CBC5
			public override int GetHashCode()
			{
				return typeof(T).GetHashCode() ^ 8510;
			}

			// Token: 0x06000CE5 RID: 3301 RVA: 0x0003E7DC File Offset: 0x0003CBDC
			public override bool Equals(Notification<T> other)
			{
				return object.ReferenceEquals(this, other) || (!object.ReferenceEquals(other, null) && other.Kind == NotificationKind.OnCompleted);
			}

			// Token: 0x06000CE6 RID: 3302 RVA: 0x0003E803 File Offset: 0x0003CC03
			public override string ToString()
			{
				return "OnCompleted()";
			}

			// Token: 0x06000CE7 RID: 3303 RVA: 0x0003E80A File Offset: 0x0003CC0A
			public override void Accept(IObserver<T> observer)
			{
				if (observer == null)
				{
					throw new ArgumentNullException("observer");
				}
				observer.OnCompleted();
			}

			// Token: 0x06000CE8 RID: 3304 RVA: 0x0003E823 File Offset: 0x0003CC23
			public override TResult Accept<TResult>(IObserver<T, TResult> observer)
			{
				if (observer == null)
				{
					throw new ArgumentNullException("observer");
				}
				return observer.OnCompleted();
			}

			// Token: 0x06000CE9 RID: 3305 RVA: 0x0003E83C File Offset: 0x0003CC3C
			public override void Accept(Action<T> onNext, Action<Exception> onError, Action onCompleted)
			{
				if (onNext == null)
				{
					throw new ArgumentNullException("onNext");
				}
				if (onError == null)
				{
					throw new ArgumentNullException("onError");
				}
				if (onCompleted == null)
				{
					throw new ArgumentNullException("onCompleted");
				}
				onCompleted();
			}

			// Token: 0x06000CEA RID: 3306 RVA: 0x0003E877 File Offset: 0x0003CC77
			public override TResult Accept<TResult>(Func<T, TResult> onNext, Func<Exception, TResult> onError, Func<TResult> onCompleted)
			{
				if (onNext == null)
				{
					throw new ArgumentNullException("onNext");
				}
				if (onError == null)
				{
					throw new ArgumentNullException("onError");
				}
				if (onCompleted == null)
				{
					throw new ArgumentNullException("onCompleted");
				}
				return onCompleted();
			}
		}
	}
}
